package com.sample.library.util

import java.io.Closeable
import java.io.File
import java.io.FileOutputStream
import java.io.IOException

/**
 * @author  ddnosh
 * @website http://blog.csdn.net/ddnosh
 */
object IOUtil {

    /**
     * Close closable object and wrap [IOException] with [ ]
     *
     * @param closeable closeable object
     */
    @JvmStatic
    fun close(closeable: Closeable?) {
        if (closeable != null) {
            try {
                closeable.close()
            } catch (e: IOException) {
                throw RuntimeException("IOException occurred. ", e)
            }
        }
    }

    /**
     * Close closable and hide possible [IOException]
     *
     * @param closeable closeable object
     */
    @JvmStatic
    fun closeQuietly(closeable: Closeable?) {
        if (closeable != null) {
            try {
                closeable.close()
            } catch (e: IOException) {
                // Ignored
            }
        }
    }

 
}
